<template>
    <div class="page">
        <div class="back" 
            style="padding: 30px;
                background: #fff;
                border: 1px solid #ddd;
                border-radius: 5px;">
            <!-- 搜索框 -->
            <div class="search">
            <el-select
            clearable
            size="medium"
            v-model="year"
            placeholder="学年"
            class="handle-select mr10"
            >
            <el-option
                v-for="item in years"
                :key="item.value"
                :label="item.label"
                :value="item"
            >
            </el-option>
            </el-select>
            <el-select
            clearable
            v-model="term"
            placeholder="学期"
            class="handle-select mr10"
            >
            <el-option
                v-for="item in terms"
                :key="item.value"
                :label="item.label"
                :value="item"
            >
            </el-option>
            </el-select>
            <el-button type="primary" icon="el-icon-search" @click="getCoursesData"
            >查询
            </el-button>
            </div>
            <el-table
                :data="tableCourses"
                border
                style="width: 100%"
                class="table"
                ref="multipleTable"
                header-cell-class-name="table-header"
            >
                <el-table-column prop="course_id" label="课程号" width="100"></el-table-column>
                <el-table-column prop="course_name" label="课程名" width="200"></el-table-column>
                <el-table-column prop="course_nature" label="课程类型" width="90">
                </el-table-column>
                <el-table-column prop="course_college" label="授课学院" width="180"></el-table-column>
                <el-table-column prop="course_teacher" label="主讲老师" width="90"></el-table-column>
                <el-table-column prop="course_credit" label="学分" width="90"></el-table-column>
                <el-table-column prop="course_time" label="学时" width="90"></el-table-column>
                <el-table-column
                    prop="course_address"
                    label="上课地点"
                    :show-overflow-tooltip="true"
                ></el-table-column>
                <el-table-column prop="course_year" label="开课年份" width="90"></el-table-column>
                <el-table-column prop="grade" label="面向年级" width="90"></el-table-column>
                <el-table-column prop="course_grade" label="所得成绩" width="90"></el-table-column>
            </el-table>
        </div>
    </div>
</template>

<script>
import { getRequest } from '@/api/index';

export default {
    name: 'StudentCourse',
    components: {},
    data() {
        return {
            year:'2020',
            term:'2',
            years:[{
                value: '2016',
                label: '2016'
                }, {
                value: '2017',
                label: '2017'
                }, {
                value: '2018',
                label: '2018'
                }, {
                value: '2019',
                label: '2019'
                }, {
                value: '2020',
                label: '2020'
                }
            ],
            terms:[{
                value: '1',
                label: '第一学期'
                }, {
                value: '2',
                label: '第二学期'
                }
            ],
            tableCourses: []
        };
    },
    created() {
        this.getCoursesData();
    },
    methods: {
        getCoursesData(){
            if(typeof(this.term)!='string'){
                this.term=this.term.value;
            }
            if(typeof(this.year)!='string')
            {
                this.year=this.year.value;
            }
            getRequest('/login/student/openclass/getold',
            {
                term:this.term,
                year:this.year
            }).then(res => {
                if (res.code == 200) {
                    console.log('获取历史课程')
                    console.log(res)
                    this.tableCourses=res.data
                }
            });
        },       
    },
};
</script>

<style>
.hide .el-upload--picture-card {
    display: none;
}
.search {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    padding-bottom: 5px;
    padding-top: 5px;
    border-bottom: 1px solid #cfcfcf;
    border-bottom: 1px solid #7c7a7a;
}

.lesson_name {
    width: 20%;
    padding-left: 10px;
    padding-right: 10px;
}
.handle-box {
    margin-bottom: 20px;
}

.handle-select {
    width: 120px;
}

.handle-input {
    width: 300px;
    display: inline-block;
}
.mr10 {
    margin-right: 10px;
}
.table {
    width: 100%;
    font-size: 14px;
}
.red {
    color: #ff0000;
}
.mr10 {
    margin-right: 10px;
}
.table-td-thumb {
    display: block;
    margin: auto;
    width: 40px;
    height: 40px;
}
.btn-add {
    float: right;
}
</style>
